SUBROUTINE BOUNDARY(WT,I)
USE DAMOD
REAL::NX,NY,WT(4)
INTEGER::A,B
	A=EDGE(1,I)
	B=EDGE(2,I)
	J=EDGE(3,I)
	DX=NODE(1,B)-NODE(1,A)
	DY=NODE(2,B)-NODE(2,A)
	S=SQRT(DX**2+DY**2)
	NX=DY/S
	NY=-DX/S
    DENI=W(1,J)
	UI=W(2,J)/W(1,J)
	VI=W(3,J)/W(1,J)
	EI=W(4,J)/W(1,J)
	HI=EI+(GAMA-1)*(EI-0.5*(UI**2+VI**2))
	PI=DENI*(HI-EI)
	SONICI=SQRT(GAMA*(HI-EI))
	VN8=U8*NX+V8*NY
    IF(VN8.GT.1.E-5)THEN
     P=P8
	DEN=DENI+(P-PI)/SONICI**2
	U=UI+NX*(PI-P)/(DENI*SONICI)
	V=VI+NY*(PI-P)/(DENI*SONICI) 
	ELSE
     P=0.5*(PI+P8-DENI*SONICI*(NX*(U8-UI)+NY*(V8-VI)))
	DEN=DEN8+(P-P8)/SONICI**2
	U=U8-NX*(P8-P)/(DENI*SONICI)
	V=V8-NY*(P8-P)/(DENI*SONICI)
	ENDIF
	  WT(1)=DEN
	  WT(2)=DEN*U
	  WT(3)=DEN*V
	  WT(4)=P/(GAMA-1)+DEN*0.5*(U**2+V**2)
	  END
